package HeiMa.CollectionStudy;

import java.util.ArrayList;

public class sortDemo {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();

        list.add("linqinxia");
        list.add("zhangmanyu");
        list.add("wangzuxian");
        list.add("liuyan");
        list.add("zhanmin");
        list.add("zhangwuji");

//        list.stream().sorted().forEach(System.out::println);

//        list.stream().sorted((s1,s2)-> s1.length()-s2.length()).forEach(
//                System.out::println
//        );

        list.stream().sorted((s1,s2)->{
            int num = s1.length() - s2.length();
            int num2 = num == 0 ? s1.compareTo(s2):num;
            return num2;
        }).forEach(System.out::println);
    }
}
